package math;

public class Math {
	
	public static float abs(float a) {
		return (a < .0f) ? -a : a;
	}

//	public static float sqrt(float a) {
//		return pow(a, .5f);
//	}
//	
//	public static float pow( float x, float y ) {
//		
//		if( y < 0 ) {
//			x = (1/x); // convert base number to fraction
//			y *= -1; // make exponent positive  
//		}
//		
//		int den = 1000; // specify arbitrary denominator     
//		int num = (int)(y*den); // find numerator     
//		int s = (num/den)+1;              
//		/***********************************************************************     
//		 * ** Variable 's' provides the power for which we multiply the base to find     
//		 * ** our starting search value.  For example, if we seek a solution for     
//		 * ** n = 8^(2/3), then we will use 8^2 or 64 as our starting value (which is     
//		 * ** generated in our next section of code.)  Why?  The solution for our     
//		 * ** problem (given that the base is positive) will always be less than or     
//		 * ** equal to the base times the numerator power.      
//		 * ************************************************************************/      
//		
//		/***********************************************************************     
//		 * ** Because we set the denominator to an arbitrary high value,     
//		 * ** we must attempt to reduce the fraction. In the example below,     
//		 * ** we find the highest allowable fraction that we can use without     
//		 * ** exceeding the limitation of our primitive data types.     
//		 * ************************************************************************/      
//		float z = Float.MAX_VALUE;      
//		while( z >= Float.MAX_VALUE ) {         
//			den -=1; // decrement denominator         
//			num = (int)(y*den); // find numerator         
//			s = (num/den)+1; // adjust starting value          
//			// find value of our base number to the power of numerator         
//			z = x;                          
//			for( int i = 1; i < num; i++ )
//				z *= x;
//		}
//		
//		/***********************************************************************     
//		 * ** Now we are going to implement the decay algorithm to find     
//		 * ** the value of 'n'.     
//		 * ************************************************************************/      
//		/***********************************************************************     
//		 * ** We now find 'n' to the power of 's'. We will then decrement 'n',     
//		 * ** finding the value of 'n' to the power of the denominator. This     
//		 * ** value, variable 'a', will be compared to 'z'. If the 'a' is nearly     
//		 * ** equal to 'z', then we will return 'n', our desired result.     
//		 * ************************************************************************/              
//		float n = x; // We define 'n' as our return value (estimate) for 'x'.      
//		// find 'n' to the power of 's'.              
//		for( int i = 1; i < s; i++)n *= x;      // Begin decay loop     
//		while( n > 0 ) {         
//			float a = n; //proxy for n          
//			// find 'a', the value of 'n' to the power of denominator         
//			for( int i = 1; i < den; i++ )
//				a *= n;          
//			// compare 'a' to 'z'. Is the value within the hundred-thousandth?         
//			// if so, return 'n'.         
//			float check1 = a-z;         
//			float check2 = z-a;                          
//			if( check1 < .001|| check2 > .001 )
//				return n;          
//			n *= .99;// We arbitrarily use a decay of .1% per iteration     
//			
//		}
//
//		// value could not be found, return -1.     
//		return -1.f;
//	}

}
